Add project variable migration support#184
Conversation
Greptile SummaryThis PR adds
Confidence Score: 4/5The settings group is unusable via extractServices until the missing match arm is added; the rest of the migration wiring is sound. The extractServices() match expression has no GROUP_SETTINGS arm, so any caller passing Transfer::GROUP_SETTINGS hits the default and throws. The remainder of the change is consistent with existing patterns. src/Migration/Transfer.php — the extractServices() match expression needs the GROUP_SETTINGS arm before the settings group is fully operational. Important Files Changed
|
| } catch (DuplicateException) { | ||
| $resource->setStatus(Resource::STATUS_SKIPPED, 'Project variable already exists'); | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| private function validateFieldsForIndexes(Index $resource, UtopiaDocument $table, array &$lengths) |
There was a problem hiding this comment.
Both
createPlatform and createApiKey call $this->dbForPlatform->purgeCachedDocument('projects', $this->project) after writing their documents. createProjectVariable omits this. If the platform's projects document caches any project-level metadata (variable counts, etc.), created variables won't be reflected until the cache naturally expires. Worth verifying against the upstream Project::Variables::Create implementation to confirm whether the purge is needed here too.
| } catch (DuplicateException) { | |
| $resource->setStatus(Resource::STATUS_SKIPPED, 'Project variable already exists'); | |
| return false; | |
| } | |
| return true; | |
| } | |
| private function validateFieldsForIndexes(Index $resource, UtopiaDocument $table, array &$lengths) | |
| } catch (DuplicateException) { | |
| $resource->setStatus(Resource::STATUS_SKIPPED, 'Project variable already exists'); | |
| return false; | |
| } | |
| $this->dbForPlatform->purgeCachedDocument('projects', $this->project); | |
| return true; | |
| } | |
| private function validateFieldsForIndexes(Index $resource, UtopiaDocument $table, array &$lengths) |
Introduces Transfer::GROUP_SETTINGS for project-level configuration resources that aren't external integrations. Project variables are the first inhabitant; webhooks will follow in a stacked PR. - New abstract Source::exportGroupSettings() with no-op stubs in CSV/JSON/Firebase/NHost sources. - Appwrite source: project variables exported via Project SDK listVariables() with cursor pagination. - Appwrite destination: createProjectVariable writes directly to dbForProject 'variables' collection, mirroring upstream Project Variables Create payload (resourceType 'project', empty resource id).
c040472 to
3376bed
Compare
- MockSource now stubs exportGroupSettings so the class is concrete (clears PHPUnit fatal + PHPStan level-3 error). - Pint ordered_imports auto-fix on Sources/Appwrite.php and Destinations/Appwrite.php.
Summary
Stacks on #183. Adds project-variable as a migrable resource using the Appwrite SDK's
Project::listVariables()(source) and a directdbForProject->createDocument('variables', ...)(destination) that mirrors upstreamProject::Variables::Createexactly.Notes
Resource::TYPE_PROJECT_VARIABLE = 'project-variable'(kebab) — placed inGROUP_INTEGRATIONS_RESOURCESalongside platform/api-key for minimum changes to other Source/Destination implementations.resourceType: 'project'(singular, as upstream does for project-scope) with emptyresourceInternalId/resourceIdand a synthesizedsearchfield.valueon read for secret variables, so secrets will arrive with empty values. Operator re-enters them on the destination side. (Same caveat as API key secrets.)